<!--
描述：招生管理-题库参数设置-编辑组件
开发人：hqj
开发日期：2018年10月26日
-->
<template lang="pug">
    kalix-dialog.user-add(bizKey="questionSetting" ref="kalixBizDialog"
    v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
        div.el-form(slot="dialogFormSlot")
            el-form-item.s-flex_item(label="题库功能是否开启" prop="available" v-bind:label-width="labelWidth")
                <!--div(style="text-align:center")-->
                el-switch(v-model="formModel.available" active-text="开启" inactive-text="关闭")
            el-form-item.s-flex_item(label="题库去重相似度" prop="similarity" v-bind:rules="rules.similarity" v-bind:label-width="labelWidth")
                el-input(v-model="formModel.similarity")
            el-form-item.s-flex_item(label="题库自动排重比对" prop="repeated" v-bind:label-width="labelWidth")
                el-switch(v-model="formModel.repeated" active-text="开启" inactive-text="关闭")
            div.s-flex
                el-form-item.s-flex_item(label="填空题比对状态" prop="compareCompletion" v-bind:label-width="labelWidth")
                    el-switch(v-model="formModel.compareCompletion" active-text="进行中" inactive-text="已结束")
                el-form-item.s-flex_item(label="单项选择题比对状态" prop="compareChoice" v-bind:label-width="labelWidth")
                    el-switch(v-model="formModel.compareChoice" active-text="进行中" inactive-text="已结束")
            div.s-flex
                el-form-item.s-flex_item(label="主观题比对状态" prop="compareSubject" v-bind:label-width="labelWidth")
                    el-switch(v-model="formModel.compareSubject" active-text="进行中" inactive-text="已结束")
                el-form-item.s-flex_item(label="面试题比对状态" prop="compareInterview" v-bind:label-width="labelWidth")
                    el-switch(v-model="formModel.compareInterview" active-text="进行中" inactive-text="已结束")
</template>

<script type="text/ecmascript-6">
    import FormModel from './model'
    import {QuestionSettingURL} from '../../config.toml'

    export default {
        name: 'QuestionSettingEdit',
        data() {
            var checkSimilarity = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('请输入题库去重相似度'));
                }
                if (/^(0.\d+|0|1)$/.test(value)) {
                    callback();
                } else {
                    callback(new Error('请输入0～1之间的数字值'));
                }
            };
            return {
                formModel: Object.assign({}, FormModel),
                rules: {
                    similarity: [{required: true, validator: checkSimilarity, trigger: 'blur'}]
                },
                targetURL: QuestionSettingURL,
                labelWidth: '180px',
            }
        },
        created() {
        },
        mounted() {
        },
        methods: {
        }
    }
</script>

<style scoped lang="stylus">
    .el-form
        padding 30px 70px 30px 20px

    .popover
        height 40px
        display flex
        align-items center
        padding-left 16px
        font-size 20px
</style>
